﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ArgusLib.Controls
{
	public partial class ExceptionDisplayBox : BaseForm
	{
		public ExceptionDisplayBox()
		{
			InitializeComponent();
		}

		public string Caption { get { return this.Text; } set { this.Text = value; } }
		public string Message { get { return this.lText.Text; } set { this.lText.Text = value; } }
		public string ExceptionText { get { return this.tbException.Text; } set { this.tbException.Text = value; } }

		private void lText_TextChanged(object sender, EventArgs e)
		{
			using (Graphics g = this.lText.CreateGraphics())
			{
				SizeF size = g.MeasureString(this.lText.Text, this.lText.Font, this.lText.Width);
				g.Dispose();
				this.lText.Height = (int)size.Height;
				this.panel1.Top = this.lText.Bottom + Math.Max(this.lText.Margin.Bottom, this.panel1.Margin.Top);
				this.ClientSize = new Size(this.ClientSize.Width, this.panel1.Bottom + this.panel1.Margin.Bottom);
			}
		}

		public static void Show(string message, string caption, string exceptionText)
		{
			ExceptionDisplayBox form = new ExceptionDisplayBox();
			form.Caption = caption;
			form.Message = message;
			form.ExceptionText = exceptionText;
			form.ShowDialog();
		}

		private void bOK_Click(object sender, EventArgs e)
		{
			this.Close();
		}
	}
}
